package com.sf.marathon.soul.core.base;

/**
 * 统一的结果码<br>
 * <p>
 * 与前端约定，前端会根据相应错误码进行路由
 * </p>
 *
 * @author liutao
 *         2017/6/19 16:19
 */
public enum ResultCodeEnum {
    SUCCESS("0", "成功"), INFO("2001", "业务提示"), NOT_FOUND("4001", "请求资源不存在"),
    TIMEOUT("4002", "未登录或登录超时"), LOGIN("2002", "登陆成功后的跳转"), UNAUTHORIZED("4003", "未授权"), ERROR("5001", "系统运行异常");

    private final String value;
    private final String info;

    ResultCodeEnum(String value, String info) {
        this.value = value;
        this.info = info;
    }

    public static ResultCodeEnum getByValue(String value) {
        ResultCodeEnum ret = null;
        for (ResultCodeEnum o : ResultCodeEnum.values()) {
            if (o.value().equals(value)) {
                ret = o;
            }
        }

        return ret;
    }

    public String info() {
        return info;
    }

    public String value() {
        return value;
    }

}
